
        Private Sub CreateRelations(ds As DataSet)
            <%
<script runat="template">
public string GetDSRelations(CslaObjectInfo info)
{
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    foreach (CslaObjectInfo item in GetCollectionChildItems(info))
    {
        if (item.ParentProperties.Count > 0)
        {
            sb.Append("            ds.Relations.Add(\"");
            sb.Append(info.ObjectName);
            sb.Append(item.ObjectName);
            sb.Append("\", New DataColumn() {");
            int i = 0;
            foreach (CslaGenerator.Metadata.Property prop in item.ParentProperties)
            {
                if (i > 0)
                    sb.Append(", ");
                sb.Append("ds.Tables(\"");
                sb.Append(info.ObjectName);
                sb.Append("\").Columns(\"");
                sb.Append(prop.Name);
                sb.Append("\")");
                i++;
            }
            i = 0;
            sb.Append("}, New DataColumn() {");
            foreach (CslaGenerator.Metadata.Property prop in item.ParentProperties)
            {
                if (i > 0)
                    sb.Append(", ");
                sb.Append("ds.Tables(\"");
                sb.Append(item.ObjectName);
                sb.Append("\").Columns(\"");
                sb.Append(prop.Name);
                sb.Append("\")");
                i++;
            }
            sb.Append("}, False)");
            sb.AppendLine();
            sb.Append(GetDSRelations(item));
        }
    }
    return sb.ToString();
}
</script>
%>
            <%
            CslaObjectInfo obj;
            if (TypeHelper.IsCollectionType(Info.ObjectType))
                obj = FindChildInfo(Info, Info.ItemType);
            else
                obj = Info;
            if (obj != null)
            {
                string[] objectNames = GetCollectionChildItemsInHierarchy(obj);
                %>
            ds.Tables(0).TableName = "<%= obj.ObjectName %>"
            <%
                for (int i = 0; i < objectNames.Length; i++)
                {
                    %>
            ds.Tables(<%= (i+1).ToString() %>).TableName = "<%= objectNames[i] %>"
            <%
                }
                %>
<%= GetDSRelations(obj) %><%
            }
            %>
        End Sub
